<template>
	<view class="home">
		<view class="header">
			<view class="text">
				<view class="headertxt">智慧社区</view>
				<view class="seacher">
					<view class="left">
						<image src="https://s1.ax1x.com/2022/11/21/zl6hc9.png" mode=""></image>
						{{buildingName.slice(0,4)}}
					</view>
					<view class="right">
						<image src="https://s1.ax1x.com/2022/11/21/zlRgbR.png" alt="">
							<input type="text" placeholder="    搜索关键字">
					</view>
				</view>
			</view>
			<view class="tabs">
				<ul>
					<li @click="$utils.toPage('/pages/home/fee/fee')">
						<view class="imgs">
							<image src="https://s1.ax1x.com/2022/11/22/zlW1d1.png" mode=""></image>
						</view>
						<text>生活缴费</text>
					</li>
					<li @click="$utils.toPage('/pages/home/repair/repair')">
						<view class="imgs" style="background-color: #71b78b;">
							<image src="https://s1.ax1x.com/2022/11/22/zlWWLj.png" mode=""></image>
						</view>
						<text>物业报修</text>
					</li>
					<li @click="$utils.toPage('/pages/home/Feedback/Feedback')">
						<view class="imgs" style="background-color: #e39e5e;">
							<image src="https://s1.ax1x.com/2022/11/22/zlWhes.png" mode=""></image>
						</view>
						<text>问题反馈</text>
					</li>
					<li @click="$utils.toPage('/pages/home/Help/Help')">
						<view class="imgs" style="background-color: #479cf7;">
							<image src="https://s1.ax1x.com/2022/11/22/zlW5oq.png" mode=""></image>
						</view>
						<text>我要帮助</text>
					</li>
				</ul>
			</view>
		</view>
		<view class="swiper">
			<view class="toptxt">
				<image src="https://s1.ax1x.com/2022/11/22/z1F4xK.png" mode=""></image>
				<text>关于我行对符合条条件的账户...</text>
				<view class="dot"></view>
				<view class="bigger">
					<text>更多</text>
					<image src="https://s1.ax1x.com/2022/11/22/z1kxYR.jpg" mode=""></image>
				</view>
			</view>
			<swiper class="swiperimg" autoplay="true" interval='2000' circular="true">
				<swiper-item>
					<image src="https://s1.ax1x.com/2022/11/22/z1FtEj.png" mode=""></image>
				</swiper-item>
				<swiper-item>
					<image src="https://s1.ax1x.com/2022/11/22/z1FtEj.png" mode=""></image>
				</swiper-item>
			</swiper>
		</view>
		<view class="live">
			<h1>生活门店</h1>
			<image src="https://s1.ax1x.com/2022/11/22/z1EEuT.png" mode=""></image>
		</view>
		<view class="Counseling">
			<view class="headertop">
				<view class="txt">资讯</view>
				<image  @click="go" src="https://s1.ax1x.com/2022/11/22/z1kxYR.jpg" mode=""></image>
			</view>
			<view class="list">
				<ul v-for="item in newsdata" :key="item.id">
					<li>
						<view class="left">
							<view class="what">
								{{item.title}}
							</view>
							<view class="time">
								{{item.addtime}}
							</view>
						</view>
						<view class="right">
							<image v-if="!item.picture" src="https://s1.ax1x.com/2022/11/22/z1n5Hf.jpg" mode=""></image>
							<image v-else :src="IMGURL+item.picture" mode=""></image>
						</view>
					</li>
				</ul>
			</view>

		</view>
		<view class="btm"></view>
	</view>

</template>

<script>
	import {newslist} from '../utils/api.js'
	import {IMG} from '../utils/cofing.js'
	export default {
		data() {
			return {
				token: uni.getStorageSync("token"),
				// 公告列表
				newsdata:[],
				// 分页
				query:{
					page:1,
					psize:3,
				},
				buildingName:'',
				IMGURL:IMG,
				// buildingName:this.$store.state.house.buildingName
			}
		},
		onShow(){
			this.$utils.checkHouseState()
		},
		onLoad(){
			if(!this.token){
				uni.reLaunch({
					url:'/pages/login/login'
				})
			}
			this.getnewslist()
			let building = uni.getStorageSync('buidings')
			console.log(building);
			this.buildingName = building[0].building
		},
		methods:{
			async getnewslist(){
				let res = await newslist(this.query)
				// console.log(res);
				if(res.errCode==10000){
					this.newsdata = res.data.list.filter(item=>{
						return item.type === 2
					})
					// console.log(this.newsdata);
				}
			},
			go(){
				uni.navigateTo({
					url:'News'
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	li {
		list-style: none;
	}

	.home {
		width: 100%;

		.header {
			width: 100%;
			height: 430rpx;
			background-color: #f6f6f6;

			.text {
				width: 100%;
				height: 345rpx;
				background-image: url("https://s1.ax1x.com/2022/11/21/zl69W4.png");
				background-size: 100%;

				.headertxt {
					width: 145rpx;
					height: 50rpx;
					// margin-top: 51rpx;
					line-height: 100rpx;
					margin-left: 307rpx;
					font-size: 32rpx;
					color: #fff;
				}

				.seacher {
					width: 685rpx;
					height: 85rpx;
					margin-left: 32rpx;
					display: flex;
					justify-content: space-between;

					.left {
						width: 170rpx;
						height: 45rpx;
						font-size: 30rpx;
						color: #fff;
						margin-top: 50rpx;
						line-height: 120rpx;

						image {
							width: 28rpx;
							height: 28rpx;
							margin-right: 10rpx;
						}
					}

					.right {
						width: 240rpx;
						height: 45rpx;
						background-color: #fff;
						margin-top: 90rpx;
						border-radius: 50rpx;
						position: relative;

						input {
							width: 240rpx;
							height: 45rpx;
							font-size: 22rpx;
							// text-align: center;
							line-height: 45rpx;
							padding: 0 20rpx;
						}

						image {
							width: 24rpx;
							height: 24rpx;
							position: absolute;
							top: 10rpx;
							left: 20rpx;
						}
					}
				}
			}

			.tabs {
				width: 685rpx;
				height: 160rpx;
				margin-left: 32rpx;
				position: absolute;
				top: 220rpx;
				background-color: #fff;
				ul {
					display: flex;
					flex: 1;

					li {
						width: 25%;
						display: flex;
						flex-wrap: wrap;
						flex-direction: column;
						align-items: center;
						font-size: 25rpx;

						.imgs {
							width: 78rpx;
							height: 78rpx;
							border-radius: 15rpx;
							background-color: #4f86ed;
							margin-top: 30rpx;
							margin-bottom: 5rpx;
							text-align: center;

							image {
								width: 50rpx;
								height: 50rpx;
								margin-top: 15rpx;
							}
						}
					}
				}

			}
		}

		.swiper {
			width: 685rpx;
			height: 377rpx;
			margin-left: 32rpx;

			.toptxt {
				width: 100%;
				height: 100rpx;
				display: flex;

				image {
					width: 87rpx;
					height: 37rpx;
					margin-top: 30rpx;
				}

				text {
					line-height: 100rpx;
					font-size: 28rpx;
					margin-left: 23rpx;
				}

				.dot {
					width: 20rpx;
					height: 20rpx;
					background-color: #ff0015;
					border-radius: 50%;
					margin-left: 35rpx;
					margin-top: 40rpx;
				}

				.bigger {
					width: 120rpx;
					height: 35rpx;
					display: flex;

					image {
						width: 28rpx;
						height: 28rpx;
						margin-top: 35rpx;
						margin-left: 10rpx;
					}
				}
			}

			.swiperimg {
				image {
					width: 100%;
					height: 252rpx;
				}
			}
		}

		.live {
			width: 100%;
			height: 327rpx;
			position: relative;

			h1 {
				width: 210rpx;
				height: 60rpx;
				font-size: 33rpx;
				font-weight: 600;
				position: absolute;
				background-color: #dcf8ff;
				line-height: 60rpx;
				text-align: center;
				top: 15rpx;
			}

			image {
				width: 100%;
				height: 327rpx;
			}
		}

		.Counseling {
			width: 685rpx;
			margin-left: 32rpx;

			.headertop {
				width: 100%;
				height: 107rpx;
				display: flex;
				justify-content: space-between;

				.txt {
					width: 87rpx;
					height: 52rpx;
					margin-top: 46rpx;
					font-size: 32rpx;
					font-weight: 600;
					text-align: center;
				}

				image {
					width: 26rpx;
					height: 32rpx;
					margin-top: 55rpx;
				}
			}

			.list li {
				width: 100%;
				height: 217rpx;
				display: flex;

				.left {
					width: 380rpx;
					height: 100%;
					display: flex;
					flex-wrap: wrap;
					flex-direction: column;
					.what {
						font-size: 26rpx;
						padding: 0 10rpx;
						margin-top: 32rpx;
					}

					.time {
						font-size: 20rpx;
						color: #585858;
						padding: 0 10rpx;
						margin-top: 70rpx;
					}
				}

				.right {
					width: 305rpx;
					height: 100%;

					image {
						width: 245rpx;
						height: 164rpx;
						border-radius: 10rpx;
						margin-top: 27rpx;
						margin-left: 56rpx;
					}
				}
			}

		}

		.btm {
			width: 100%;
			height: 200rpx;
		}
	}
</style>
